/* 储存供应商管理-基础设置api */

import { ajaxService } from '@/utils/request';

const env = import.meta.env;
let baseURL = env.VITE_SUPPLOER_URL;

// 获取供应商编号数据
export function GetSupplierCodeInfo() {
  return ajaxService({
    url: '/supplier/set/num',
    method: 'get',
    baseURL,
  });
}

// 修改供应商编号
export function PostSupplierCodeInfo(data: any) {
  return ajaxService({
    url: '/supplier/set/num',
    method: 'post',
    baseURL,
    data,
  });
}

// 获取供应商级别数据
export function GetSupplierLevelInfo() {
  return ajaxService({
    url: '/supplier/set/level',
    method: 'get',
    baseURL,
  });
}

// 修改供应商级别
export function PostSupplierLevelInfo(data: any) {
  return ajaxService({
    url: '/supplier/set/level',
    method: 'post',
    baseURL,
    data,
  });
}

// 获取供应商类别数据
export function GetSupplierCategoryInfo() {
  return ajaxService({
    url: '/supplier/set/category',
    method: 'get',
    baseURL,
  });
}

// 修改供应商类别
export function PostSupplierCategoryInfo(data: any) {
  return ajaxService({
    url: '/supplier/set/category',
    method: 'post',
    baseURL,
    data,
  });
}

// 获取供应商评级数据
export function GetSupplierRateInfo() {
  return ajaxService({
    url: '/supplier/set/grade',
    method: 'get',
    baseURL,
  });
}

// 修改供应商评级
export function PostSupplierRateInfo(data: any) {
  return ajaxService({
    url: '/supplier/set/grade',
    method: 'post',
    baseURL,
    data,
  });
}

// 获取供应商状态数据
export function GetSupplierStateInfo() {
  return ajaxService({
    url: '/supplier/set/state',
    method: 'get',
    baseURL,
  });
}

// 修改供应商状态
export function PostSupplierStateInfo(data: any) {
  return ajaxService({
    url: '/supplier/set/state',
    method: 'post',
    baseURL,
    data,
  });
}

// 删除供应商状态
export function DelSupplierStateInfo(data: any) {
  return ajaxService({
    url: '/supplier/set/state',
    method: 'delete',
    baseURL,
    data,
  });
}

// 获取供应商模板列表数据
export function GetSupplierTemplateListInfo(params?: any) {
  return ajaxService({
    url: '/supplier/set/temp/getAll',
    method: 'get',
    baseURL,
    params,
  });
}

// 获取供应商模板详情数据
export function GetSupplierTemplateDetailInfo(params: any) {
  return ajaxService({
    url: '/supplier/set/temp/getById',
    method: 'get',
    baseURL,
    params,
  });
}

// 添加供应商模板数据
export function PostSupplierTemplateInfo(data: any) {
  return ajaxService({
    url: '/supplier/set/temp/add',
    method: 'post',
    baseURL,
    data,
  });
}

// 修改供应商模板数据
export function PutSupplierTemplateInfo(data: any) {
  return ajaxService({
    url: '/supplier/set/temp/edit',
    method: 'put',
    baseURL,
    data,
  });
}

// 修改供应商模板状态
export function PutSupplierTemplateStateInfo(data: any) {
  return ajaxService({
    url: '/supplier/set/temp/editState',
    method: 'put',
    baseURL,
    data,
  });
}

// 删除供应商模板
export function DelSupplierTemplateInfo(params: any) {
  return ajaxService({
    url: '/supplier/set/temp/del',
    method: 'delete',
    baseURL,
    params,
  });
}

// 获取供应商认证
export function getSupplierauth() {
  return ajaxService({
    url: '/supplier/set/auth/get',
    method: 'get',
    baseURL,
  });
}

export interface postSupplierauth {
  authType: number;
  name: string;
  description: string;
}

// 新增供应商认证
export function postSupplierauth(data: postSupplierauth) {
  return ajaxService({
    url: '/supplier/set/auth/add',
    method: 'post',
    data,
    baseURL,
  });
}

export interface putSupplierauth {
  id: number;
  authType: number;
  name: string;
  description: string;
}
// 修改供应商认证
export function putSupplierauth(data: putSupplierauth) {
  return ajaxService({
    url: '/supplier/set/auth/edit',
    method: 'put',
    data,
    baseURL,
  });
}

// 删除供应商认证
export function delSupplierauth(params: any) {
  return ajaxService({
    url: '/supplier/set/auth/del',
    method: 'delete',
    params,
    baseURL,
  });
}

// 获取供应商认证
export function getSupplierList(params?: any) {
  return ajaxService({
    url: '/supplier/auth/show/list',
    method: 'get',
    params,
    baseURL,
  });
}

// 添加供应商认证
export function addSupplierauth(data: any) {
  return ajaxService({
    url: '/supplier/auth/add',
    method: 'post',
    data,
    baseURL,
  });
}

// 删除供应商类别
export function deleteSupplierCategory(data: any) {
  return ajaxService({
    url: '/supplier/set/category',
    method: 'delete',
    data,
    baseURL,
    // paramsSerializer(params) {
    //   let result = [];
    //   for (let field in params) {
    //     if (params[field] === undefined || params[field] === null) {
    //       result.push(`${field}=`);
    //       // eslint-disable-next-line no-continue
    //       continue;
    //     }
    //     if (Array.isArray(params[field])) {
    //       result.push(params[field].map((_) => `${field}=${_}`).join('&'));
    //     } else {
    //       result.push(`${field}=${encodeURIComponent(params[field])}`);
    //     }
    //   }
    //   return result;
    // },
  });
}
